//
//  SetViewController.m
//  PCNews
//
//  Created by PengchengWang on 16/3/9.
//  Copyright © 2016年 pengchengWang. All rights reserved.
//

#import "SetViewController.h"
#import "AppDelegate.h"

@interface SetViewController ()

@property (weak, nonatomic) IBOutlet UISlider *sliderLuminance;



@end

@implementation SetViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setViews];
    // Do any additional setup after loading the view from its nib.
}

-(void)setViews{
    self.mbPreHUD.hidden = YES;
    [self.sliderLuminance addTarget:self action:@selector(sliderLuminanceAction:) forControlEvents:UIControlEventValueChanged];
    NSUserDefaults *luminance = [NSUserDefaults standardUserDefaults];
    NSNumber *luminanceNum = [luminance valueForKey:@"luminance"];
    float luminanceValue = [luminanceNum floatValue];
    luminanceValue = luminanceValue?luminanceValue:1.0;
    self.sliderLuminance.value = luminanceValue;
    
    
}

-(void)sliderLuminanceAction:(UISlider*)sender{
    NSUserDefaults *luminance = [NSUserDefaults standardUserDefaults];
    [luminance setValue:[NSNumber numberWithFloat:sender.value] forKey:@"luminance"];
    UIWindow *window = [UIApplication sharedApplication].keyWindow;
    window.alpha = sender.value;
    
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
